package com.xbts.screen.service.impl;

import com.xbts.common.core.enums.WorkshopTypeEnum;
import com.xbts.common.core.web.domain.BaseHistogramResult;
import com.xbts.common.core.web.domain.BasePieChartResult;
import com.xbts.screen.domain.workshop.dto.CommonQueryDTO;
import com.xbts.screen.domain.workshop.vo.*;
import com.xbts.screen.mapper.FormingMapper;
import com.xbts.screen.service.IFormingService;
import com.xbts.screen.service.IWorkshopCommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 成型
 */
@Service
public class FormingServerImpl implements IFormingService {

    @Autowired
    private FormingMapper formingMapper;
    @Autowired
    private IWorkshopCommonService workshopCommonService;

    @Override
    public RealTimeAchievementRateVO realTimeAchievementRate() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.realTimeAchievementRate(dto);
    }

    @Override
    public BaseHistogramResult tenDaysAchievementRate() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.tenDaysAchievementRate(dto);
    }

    @Override
    public StatisticalRateGroupByTimeVO achievementRateGroupByTimeType() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.achievementRateGroupByTimeType(dto);
    }

    @Override
    public BaseHistogramResult waterUnitConsume() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.waterUnitConsume(dto);
    }

    @Override
    public BaseHistogramResult electricityUnitConsume() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.electricityUnitConsume(dto);
    }

    @Override
    public List<ProductionScheduleVO> productionSchedule() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.productionSchedule(dto);
    }

    @Override
    public BaseHistogramResult turnoverRate() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.turnoverRate(dto);
    }

    @Override
    public StatisticalRateGroupByTimeVO turnoverRateGroupByTimeType() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.turnoverRateGroupByTimeType(dto);
    }

    @Override
    public PassRateVO verifyPassRate() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.passRate(dto);
    }

    @Override
    public List<BasePieChartResult> verifyBadStatistics() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.badStatistics(dto);
    }

    @Override
    public ScrapRateVO firstArticlePassRate() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.scrapRate(dto);
    }

    @Override
    public BaseHistogramResult verifyPassRateTrend() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.passRateTrend(dto);
    }

    @Override
    public List<BasePieChartResult> badStatistics() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.scrapStatistics(dto);
    }

    @Override
    public List<PassRateRecordVO> passRateRecord() {
        CommonQueryDTO dto = new CommonQueryDTO();
        dto.setDeptNames(Arrays.asList(WorkshopTypeEnum.FORMING.getErpValue().split(",")));
        return workshopCommonService.passRateRecord(dto);
    }
}